package com.example.frame_java;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.util.Log;

import com.example.frame_java.utlis.OkhtttpUtlis;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private MainActivity context;
    private String  TAG = "TAG";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        vpmap();
        context = this;
    }

    private void vpmap() {
        ViewPager vp =  findViewById(R.id.vp);
        OkhtttpUtlis.doRequst("/prod-api/api/rotation/list",
                OkhtttpUtlis.GET,
                VpmapBean.class, new OkhtttpUtlis.Netword() {
                    @Override
                    public void ok(Object obj) {
                        VpmapBean vpmapBean  = (VpmapBean)obj;
                        if(vpmapBean.getCode()==200){
                            ArrayList<String> arrayList = new ArrayList();
                            for (VpmapBean.RowsDTO row : vpmapBean.getRows()) {
                                arrayList.add(row.getAdvImg());
                            }
                            OkhtttpUtlis.doCarouselMap(vp,context,arrayList);
                            Log.v("tag",obj.toString());
                        }
                    }

                    @Override
                    public void no(String mas) {

                    }
                });
    }
}